package me.minecraft.woodenman.command;

import me.minecraft.woodenman.WoodenMan;
import me.minecraft.woodenman.config.Language;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

/**
 * @author langle__
 * @version 1.0
 */
public class SetCommand extends SubCommand {

    @Override
    public String getName() {
        return "set";
    }

    @Override
    public void onCommand(CommandSender sender, String[] args) {
        if (args.length <= 1) {
            return;
        }
        if (!(sender instanceof Player)) {
            sender.sendMessage(Language.ONLY_PLAYER_CAN_USE);
            return;
        }
        Player player = (Player) sender;
        String cmd = args[1];
        switch (cmd) {
            case "spawn":
                WoodenMan.playerLocation = player.getLocation().clone();
                sender.sendMessage(Language.SPAWN_SET_SUCCESS);
                break;
            case "woodenman":
                WoodenMan.woodenManLocation = player.getLocation().clone();
                sender.sendMessage(Language.WOODENMAN_SET_SUCCESS);
                break;
            default:
                sender.sendMessage(Language.UNKNOWN_SUBCOMMAND);
                break;
        }
    }

}
